<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/static/kindeditor/themes/default/default.css"/>
		<script charset="utf-8" src="/static/kindeditor/kindeditor-all.js"></script>
		<script charset="utf-8" src="/static/kindeditor/lang/zh-CN.js"></script>
	</head>
	<body>
		<form action="" id="form" onsubmit="return false"><!--method="post"-->
			<input type="file" name="f" id="file" value="" />
			<input type="text" name="text" id="txt" value="" />
			<input type="button" id="btn" value="上传" />
			
		</form>
		
		<div id="div1">
			<form action="" id="form" method="post">
				<textarea id="editor_id"  name="content" style="width:1000px;height:500px;">
				&lt;strong&gt;HTML内容&lt;/strong&gt;
				</textarea>
			</form>
		</div>
		
		<script src="bck/static/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
						var arr=[
        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
        'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
        'anchor', 'link', 'unlink', '|', 'about'
];
			var editor;
			KindEditor.ready(function(K) {
                editor = K.create('#editor_id',{
                	//items:['undo', 'redo']	只出现两个undo	后退redo	前进按钮
                	items:arr,	//设置工具栏的按钮
                	uploadJson : '/ajax.php?ajax=upload',	//文件上传程序
					fileManagerJson : '/ajax.php?ajax=file_manager',	//浏览服务器图片空间
					allowFileManager : true,//启用图片空间按钮
                });
                
        	});
			
			
			$("#btn").click(function(){
				//console.log(new FormData($("#form")[0]));
				$.ajax({
					type:"post"
					,url:"/img1.php"
					,async:true  //请求同步还是异步
					,data:(new FormData($("#form")[0]))
					,processData: false	// 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
					,contentType: false // 告诉jQuery不要去设置Content-Type请求头
					,success:function(mgs){
						console.log(mgs);
						editor.html('<img src="'+mgs+'"/>');
					}
					,error:function(){
						alert("错误");
					}
				});
			});
			
			
			
			
			
			
			
			
			

		
		</script>
	</body>
</html>
